package com.tanhua.server.controller;

import com.tanhua.model.vo.UserInfoVo;
import com.tanhua.server.service.UserInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserInfoService userInfoService;


    /**
     * 新用户添加用户资料
     *
     * @return
     */
    @PostMapping("/loginReginfo")
    public ResponseEntity Reginfo(@RequestBody UserInfoVo userInfoVo) {

        userInfoService.Userinfo(userInfoVo);

        return ResponseEntity.ok("添加成功");
    }

    /**
     * 图片上传到阿里云OSS存储
     *
     * @param headPhoto
     * @return
     * @throws Exception
     */
    @PostMapping("/loginReginfo/head")
    public ResponseEntity ReginfoHead(MultipartFile headPhoto) throws Exception {
        userInfoService.upload(headPhoto);
        return ResponseEntity.ok(null);
    }


}
